home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Sept, 2002
- // Author: bb
- //
- // Procedure Name:
- // doRemoveConstraintTarget
- //
- // Description:
- // The user selects the target and the constrained object.
- // This script removes the selected target from the constraint
- // so that it no longer affects the object.
- //
- // Input Arguments:
- // $version: The version of this option box. Used to know how to
- // interpret the $args array.
- // "1" : first verison
- //
- // $args
- // Version 1
- // [0] $which : comma separated string of constraint types to affect, or "all" to remove the target from all existing constraint on the object
- // [1] $maintainOffset: whether to maintain the existing offset to the remaining targets
- //
- // Return Value:
- // none
- //
-
-
- global proc
- doRemoveConstraintTarget( string $version, string $args[] )
- {
- string $sel[] = `ls -sl`;
- if (size($sel) < 2) {
- error("You must select one or more target(s) followed by the constrained object.");
- return;
- }
-
- string $cmd;
- string $constrainedObj = $sel[size($sel)-1];
-
- int $maintainOffset = $args[1] ;
- string $remFlag = " -remove;";
- string $remMaintainOffsetFlag;
- if ($maintainOffset) {
- $remMaintainOffsetFlag = " -remove -maintainOffset; ";
- } else {
- $remMaintainOffsetFlag = " -remove; ";
- }
-
- if ($args[0] == "all") {
- string $p1 = `pointConstraint -q $constrainedObj`;
- if (size($p1)) {
- $cmd += "pointConstraint"+$remMaintainOffsetFlag;
- }
- string $a1 = `aimConstraint -q $constrainedObj`;
- if (size($a1)) {
- $cmd += "aimConstraint"+$remMaintainOffsetFlag;
- }
- string $o1 = `orientConstraint -q $constrainedObj`;
- if (size($o1)) {
- $cmd += "orientConstraint"+$remMaintainOffsetFlag;
- }
- string $s1 = `scaleConstraint -q $constrainedObj`;
- if (size($s1)) {
- $cmd += "scaleConstraint"+$remMaintainOffsetFlag;
- }
- string $par1 = `parentConstraint -q $constrainedObj`;
- if (size($par1)) {
- $cmd += "parentConstraint"+$remMaintainOffsetFlag;
- }
- string $g1 = `geometryConstraint -q $constrainedObj`;
- if (size($g1)) {
- $cmd += "geometryConstraint"+$remFlag;
- }
- string $t1 = `tangentConstraint -q $constrainedObj`;
- if (size($t1)) {
- $cmd += "tangentConstraint"+$remFlag;
- }
- string $n1 = `normalConstraint -q $constrainedObj`;
- if (size($n1)) {
- $cmd += "normalConstraint"+$remFlag;
- }
- if (nodeType($constrainedObj) == "ikHandle") {
- // the poleVectorConstraint is only valid on ikHandles
- //
- string $pv1 = `poleVectorConstraint -q $constrainedObj`;
- if (size($pv1)) {
- $cmd += "poleVectorConstraint"+$remFlag;
- }
- }
- } else {
- string $buff[];
- tokenize($args[0],",",$buff);
- for ($constraint in $buff) {
- if ($constraint == "poleVector" &&
- nodeType($constrainedObj) != "ikHandle") {
- // the poleVectorConstraint is only valid on ikHandles
- //
- continue;
- }
- $tmpCmd = ($constraint+"Constraint -q "+$constrainedObj);
- string $ex = `eval $tmpCmd`;
- if (size($ex)) {
- $cmd += ($constraint+"Constraint"+$remFlag);
- }
- }
- }
- if (size($cmd) == 0) {
- error("A constrained object must be the last object selected.");
- }
- evalEcho $cmd;
- }
-